package com.example.demo.controller;

import com.example.demo.entity.SysUser;
import com.example.demo.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Tag(name = "用户管理")
@RestController
@RequestMapping("/sys-user")
public class SysUserController {

    private final SysUserService sysUserService;

    public SysUserController(SysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }

    @Operation(summary = "用户列表")
    @GetMapping("/list")
    public List<SysUser> list() {
        return sysUserService.list();
    }

    @Operation(summary = "添加用户")
    @PostMapping("/addUser")
    public SysUser addUser(@RequestBody SysUser sysUser) {
        return null;
    }


    @Operation(summary = "管理员添加用户")
    @Parameters({
            @Parameter(name = "id",description = "文件id",in = ParameterIn.PATH),
            @Parameter(name = "token",description = "请求token",required = true,in = ParameterIn.HEADER),
            @Parameter(name = "name",description = "文件名称",required = true,in=ParameterIn.QUERY)
    })
    @PostMapping("/admin/add")
    public SysUser addUser(@PathVariable("id") String id,
                           @RequestHeader("token") String token,
                           @RequestParam("name")String name,
                           @RequestBody SysUser sysUser) {
        return null;
    }
}
